package com.edu.study.base.rest;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.edu.base.ums.member.domain.ClsMember;
import com.edu.base.ums.member.mapper.ClsMemberMapper;
import com.edu.study.base.StuCommonClassifyCatalog.domain.StuCommonClassifyCatalog;
import com.edu.study.base.StuCommonClassifyCatalog.service.IStuCommonClassifyCatalogService;
import com.edu.study.base.stuCourseExercisesResult.domain.CourseExercisesResultDetail;
import com.edu.study.base.stuCourseExercisesResult.domain.CourseExercisesResultVO;
import com.edu.study.base.stuCourseExercisesResult.domain.StuCourseExercisesResult;
import com.edu.study.base.stuCourseExercisesResult.service.IStuCourseExercisesResultService;
import com.edu.study.base.stuCourseWordClean.domain.StuCourseWordClean;
import com.edu.study.base.stuCourseWordClean.service.IStuCourseWordCleanService;
import com.edu.study.base.stuLevel.domain.StuLevel;
import com.edu.study.base.stuLevel.service.IStuLevelService;
import com.edu.study.base.stuProductCatalog.domain.StuProductCatalog;
import com.edu.study.base.stuProductCatalog.service.IStuProductCatalogService;
import com.edu.study.base.stuQuestionLibrary.domain.StuQuestionLibraryRy;
import com.edu.study.base.stuQuestionLibrary.service.IStuQuestionLibraryRyService;
import com.edu.study.base.stuQuestionRelation.service.IStuQuestionRelationRyService;
import com.edu.study.base.utils.vo.CourseWordVo;
import com.edu.study.base.wordAttributeDetail.domain.WordAttributeDetail;
import com.edu.study.base.wordAttributeDetail.service.IWordAttributeDetailService;
import com.edu.study.base.wordLearn.domain.EduWordLearn;
import com.edu.study.base.wordLearn.service.IEduWordLearnService;
import com.edu.study.base.wordLibrary.domain.wordLibrary;
import com.edu.study.base.wordLibrary.service.IwordLibraryService;
import com.edu.study.entities.po.EduWordLearnNew;
import com.edu.study.entities.po.EduWordLibrary;
import com.edu.study.service.EduWordLearnNewService;
import com.edu.study.service.EduWordService;
import com.edu.utils.AiUtil;
import com.edu.utils.UserContextUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author zuowei
 * @version 1.0
 * @date 2021-06-27 10:37
 */
@Api(tags = "5、课程相关接口")
@RestController
@RequestMapping("/api/course")
public class AppProductCatalogController extends BaseController {

    @Autowired
    private IStuProductCatalogService productCatalogService;
    @Autowired
    private IStuCommonClassifyCatalogService stuCommonClassifyCatalogService;
    @Autowired
    private ISysConfigService sysConfigService;
    @Autowired
    private IStuQuestionRelationRyService stuQuestionRelationRyService;
    @Autowired
    private IStuQuestionLibraryRyService stuQuestionLibraryRyService;
    @Autowired
    private IwordLibraryService wordLibraryService;
    @Autowired
    private IEduWordLearnService wordLearnService;

    @Autowired
    private IStuCourseExercisesResultService stuCourseExercisesResultService;
    @Autowired
    private IStuLevelService stuLevelService;
    @Autowired
    private IStuCourseWordCleanService stuCourseWordCleanService;
    @Autowired
    private ClsMemberMapper clsMemberMapper;


    @ApiOperation(value = "获取所有课程级别及其对应的阶梯目录")
    @GetMapping("/getCourseCatalogLevel")
    public TableDataInfo getCourseCatalogLevel() {
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        List<StuProductCatalog> list = productCatalogService.selectProductCatalogList(stuProductCatalog);

//    List<?> nullList = list.stream().filter(c -> c.getCatalogLevel() == null).collect(Collectors.toList());
//
//    logger.error("没有目录等级 catalogLevel 的目录列表:{}", nullList);

        List<StuProductCatalog> list1 = list.stream().filter(c -> c.getCatalogLevel() != null && c.getCatalogLevel().equals(1L)).collect(Collectors.toList());
        for (StuProductCatalog p : list1) {
            List<StuProductCatalog> childrens = list.stream().filter(c -> c.getCourseParentId().equals(p.getId())).collect(Collectors.toList());
            p.setChildren(childrens);
        }
        return getDataTable(list1);
    }

    @ApiOperation(value = "获取课程级别下的阶梯", hidden = true)
    @ApiImplicitParam(name = "id", value = "课程级别id", required = true)
    @GetMapping("/getCourseLadder")
    public TableDataInfo getCourseLadder(String id) {
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setCourseParentId(id);
        stuProductCatalog.setIfShow("1");
        List<StuProductCatalog> list = productCatalogService.selectProductCatalogList(stuProductCatalog);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取阶梯下的课程列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "会员id", required = true),
            @ApiImplicitParam(name = "id", value = "阶梯id", required = false),
            @ApiImplicitParam(name = "isFree", value = "是否免费：0-免费，1-收费, 2-试听", required = false),
            @ApiImplicitParam(name = "courseId", value = "课程ID", required = false)
    })
    @GetMapping("/getCourseCatalogList")
    public TableDataInfo getCourseCatalogList(String memberId, String id, String isFree, String courseId) {
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setId(courseId);
        stuProductCatalog.setCourseParentId(id);
        stuProductCatalog.setIfShow("1");
        stuProductCatalog.setIsFree(isFree);
        stuProductCatalog.setMemberId(memberId);
        List<StuProductCatalog> list = productCatalogService.selectCourseList(stuProductCatalog);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取阶梯下所有课程的音频列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "catalogId", value = "阶梯id", required = true)
    })
    @GetMapping("/getCourseAudios")
    public TableDataInfo getCourseAudios(String catalogId) {
        //查询阶梯下的所有课程
        StuQuestionLibraryRy questionLibrary = new StuQuestionLibraryRy();
        questionLibrary.setParentId(catalogId);
        questionLibrary.setIfQuestionShow("1");
        List<StuQuestionLibraryRy> list = stuQuestionLibraryRyService.selectCourseAudioList(questionLibrary);
        List<Map<String, Object>> volist = new ArrayList<>();
        for (StuQuestionLibraryRy q : list) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", q.getId());
            map.put("questionName", q.getQuestionName());
            map.put("audioUrl", q.getQuestionAudioUrl());
            map.put("audioSlowUrl", q.getQuestionSlowAudioUrl());
            map.put("audioFastUrl", q.getQuestionFastAudioUrl());
            map.put("audioEn", q.getQuestionTitle());
            map.put("audioCn", q.getTextAnswer());
            volist.add(map);
        }
        return getDataTable(volist);

    }


    @ApiOperation(value = "获取全部课程目录结构", hidden = true)
    @GetMapping("/getCourseCatalog")
    public TableDataInfo getCourseCatalog() {
        String wyd_product_id = sysConfigService.selectConfigByKey("wyd_product_id");
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setIfShow("1");
        List<StuProductCatalog> catalogList = productCatalogService.selectProductCatalogList(stuProductCatalog);
        stuProductCatalog.setId(wyd_product_id);
        List<StuProductCatalog> list = productCatalogService.getProductCatalogChildrens(catalogList, stuProductCatalog);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取课程主页目录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "会员id", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", required = true)
    })
    @GetMapping("/getCourseClassifyCatalog")
    public TableDataInfo getCommonClassifyCatalog(String memberId, String courseId) {
        StuCommonClassifyCatalog stuCommonClassifyCatalog = new StuCommonClassifyCatalog();
        stuCommonClassifyCatalog.setMemberId(memberId);
        stuCommonClassifyCatalog.setBelongProductId(courseId);
        stuCommonClassifyCatalog.setCatalogParentId("0");
        List<StuCommonClassifyCatalog> classifyCatalogList = stuCommonClassifyCatalogService.selectStuCommonClassifyCatalogList(stuCommonClassifyCatalog);
        //List<StuCommonClassifyCatalog> list = commonClassifyCatalogService.buildClassifyCatalogTree(classifyCatalogList, stuCommonClassifyCatalog);
        return getDataTable(classifyCatalogList);
    }

    @Autowired
    private EduWordLearnNewService wordLearnNewService;
    @Autowired
    private IWordAttributeDetailService wordAttributeDetailService;

    @ApiOperation(value = "获取课程生词")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "会员id", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", required = true)
    })
    @GetMapping("/getCourseWords")
    public TableDataInfo getCourseWords(String memberId, String courseId) {
        wordLibrary wl = new wordLibrary();
        wl.setCourseId(courseId);
        wl.setMemberId(memberId);
        List<wordLibrary> wordList = wordLibraryService.selectCourseWord(wl);

        if (!wordList.isEmpty()) {
            List<String> ids = wordList.stream().map(wordLibrary::getId).collect(Collectors.toList());

//      List<WordAttributeDetail> details = wordAttributeDetailService.list(new LambdaQueryWrapper<WordAttributeDetail>()
//              .in(WordAttributeDetail::getWordId, ids)
//      );
//      Map<String, List<WordAttributeDetail>> detailGroup = details.stream().collect(Collectors.groupingBy(WordAttributeDetail::getWordId));

            List<EduWordLearnNew> learns = wordLearnNewService.list(new LambdaQueryWrapper<EduWordLearnNew>()
                    .eq(EduWordLearnNew::getMemberId, memberId)
                    .eq(EduWordLearnNew::getKo, 2)
            );
            Map<String, EduWordLearnNew> learnMap = learns.stream().collect(Collectors.toMap(EduWordLearnNew::getWordId, i -> i));

            // 从课程词书中获取单词
            List<EduWordLearnNew> study = wordLearnNewService.list(new LambdaQueryWrapper<EduWordLearnNew>()
                    .eq(EduWordLearnNew::getMemberId, memberId)
                    .eq(EduWordLearnNew::getKo, 1)
                    .in(EduWordLearnNew::getWordId, ids)
            );
            Map<String, EduWordLearnNew> studyMap = study.stream().collect(Collectors.toMap(EduWordLearnNew::getWordId, i -> i));

            for (wordLibrary w : wordList) {
                w.setIsCollect(learnMap.containsKey(w.getId()));
                w.setIsStudy(studyMap.containsKey(w.getId()));
            }
        }
        return getDataTable(wordList);
    }

    @ApiOperation(value = "更新课程生词学习状态")
    @PostMapping("/updateCourseWordStatus")
    public AjaxResult updateCourseWordStatus(@RequestBody CourseWordVo courseWordVo) {

        List<String> wordList = courseWordVo.getWordIdList();
        if (wordList != null && wordList.size() > 0) {
            List<StuCourseWordClean> stuCourseWordCleanList = new ArrayList<>();
            wordList.forEach(w -> {
                StuCourseWordClean stuCourseWordClean = new StuCourseWordClean();
                stuCourseWordClean.setWordId(w);
                stuCourseWordClean.setMemberId(courseWordVo.getMemberId());
                stuCourseWordClean.setCourseId(courseWordVo.getCourseId());
                stuCourseWordClean.setWordStatus("1");
                stuCourseWordClean.setCreateTime(new Date());
                stuCourseWordCleanList.add(stuCourseWordClean);
            });
            stuCourseWordCleanService.insertStuCourseWordCleanList(stuCourseWordCleanList);
        }
        return AjaxResult.success();
    }

    @ApiOperation(value = "获取指定数量的试听课程")
    @GetMapping("/getTestCourses")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit", value = "数据条数", defaultValue = "0"),
    })
    public TableDataInfo getTestCourses(String limit) {
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setIfShow("1");//显示
        stuProductCatalog.setIsFree("2");//试听
        List<StuProductCatalog> list = productCatalogService.selectProductCatalogList(stuProductCatalog);
        if (!"0".equals(limit)) {
            Integer num = Integer.valueOf(limit);
            if (num <= list.size()) {
                list = list.subList(0, num);
            } else {
                num = list.size();
                list = list.subList(0, num);
            }
        }
        return getDataTable(list);
    }

    @ApiOperation(value = "【改】获取指定数量的试听课程")
    @GetMapping("/getTestCoursesEnhance")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit", value = "数据条数", defaultValue = "0"),
            @ApiImplicitParam(name = "catalogLevel", value = "目录等级，2为阶梯级别", defaultValue = "2"),
            @ApiImplicitParam(name = "catalogId", value = "目录id，获取指定目录下的试听课程，可传入等级、阶梯id", defaultValue = "123123"),

    })
    public TableDataInfo getTestCoursesEnhance(
            @RequestParam(value = "limit", required = false) Integer limit,
            @RequestParam(value = "catalogLevel", required = false) Integer catalogLevel,
            @RequestParam(value = "catalogId", required = false) String catalogId
    ) {

        List<StuProductCatalog> result = new ArrayList<>();

        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setIfShow("1");//显示
        stuProductCatalog.setIsFree("2");//试听

        // 设置目录层级
        if (catalogLevel != null) {
            stuProductCatalog.setCatalogLevel(catalogLevel.longValue());
        }

        List<StuProductCatalog> allCatalogs = productCatalogService.selectProductCatalogList(stuProductCatalog);

        if (catalogId != null) {

            /**
             * 查找目录ID为 catalogId 的目录，然后递归查找所有的子目录
             */
            Map<String, List<StuProductCatalog>> parentMap = new HashMap<>();

            for (StuProductCatalog stu : allCatalogs) {
                parentMap
                        .computeIfAbsent(stu.getCourseParentId(), k -> new ArrayList<>())
                        .add(stu);
            }
            List<StuProductCatalog> newList = new ArrayList<>();
            Queue<String> queue = new LinkedList<>();
            queue.add(catalogId);

            while (!queue.isEmpty()) {
                String currentCatalogId = queue.poll();
                List<StuProductCatalog> children = parentMap.get(currentCatalogId);

                if (children != null) {
                    for (StuProductCatalog child : children) {
                        newList.add(child);
                        queue.add(child.getId());
                    }
                }
            }
            result = newList;

        } else {
            result = allCatalogs;
        }

        if (limit != null && limit > 0) {
            Integer num = Integer.valueOf(limit);
            if (num <= result.size()) {
                result = result.subList(0, num);
            } else {
                num = result.size();
                result = result.subList(0, num);
            }
        }
        return getDataTable(result);
    }


    @ApiOperation(value = "根据用户等级获取试听课程")
    @GetMapping("/getTryCourses")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "用户等级(1 初级，2 中级，3 高级，4 超越级，5 精通级)", required = true),
            @ApiImplicitParam(name = "limit", value = "数据条数", defaultValue = "0"),
    })
    public TableDataInfo getTryCourses(String level, String limit) {
        StuProductCatalog stuProductCatalog = new StuProductCatalog();
        stuProductCatalog.setIfShow("1");
        StuLevel stuLevel = new StuLevel();
        stuLevel.setLevelNum(level);
        List<StuLevel> stuLevels = stuLevelService.selectStuLevelList(stuLevel);
        if (stuLevels != null && stuLevels.size() > 0) {
            StuLevel stuLevel1 = stuLevels.get(0);
            stuProductCatalog.setLevelId(stuLevel1.getId() + "");
        }
        List<StuProductCatalog> list = productCatalogService.selectProductCatalogList(stuProductCatalog);
        StuProductCatalog productCatalog = list.get(0);
        stuProductCatalog.setIsFree("2");
        stuProductCatalog.setLevelId(null);
        stuProductCatalog.setCourseParentId(productCatalog.getId());
        list = productCatalogService.selectProductCatalogList(stuProductCatalog);
        if (!"0".equals(limit)) {
            Integer num = Integer.valueOf(limit);
            if (num <= list.size()) {
                list = list.subList(0, num);
            } else {
                num = list.size();
                list = list.subList(0, num);
            }
        }

        return getDataTable(list);
    }


    @ApiOperation(value = "添加课文生词到课文词汇")
    @PostMapping("addWordToPool")
    public AjaxResult addWordToPool(@RequestBody CourseWordVo wordVo) {

        if (wordVo.getWordIdList() != null && wordVo.getWordIdList().size() > 0) {
            List<EduWordLearn> wordCleanList = new ArrayList<>();
            for (String wid : wordVo.getWordIdList()) {
                EduWordLearn wordClean = new EduWordLearn();
                wordClean.setWordId(wid);
                //单词来源1：课文
                wordClean.setWordSource("1");
                wordClean.setWordSourceid(wordVo.getCourseId());
                wordClean.setMemberId(wordVo.getMemberId());
                wordClean.setKo(-1L);
                wordClean.setCreateDate(new Date());
                wordCleanList.add(wordClean);
            }
            wordLearnService.insertEduWordLearnList(wordCleanList);
        }

        return AjaxResult.success();
    }


    @ApiOperation(value = "获取课程学习或课程精讲的内容")
    @ApiImplicitParam(name = "bussId", value = "课程学习或课程精讲目录id", required = true)
    @GetMapping("/getCourseClean")
    public TableDataInfo getCourseClean(String bussId) {
        StuQuestionLibraryRy questionLibrary = new StuQuestionLibraryRy();
        questionLibrary.setBussId(bussId);
        questionLibrary.setBussTableName("stu_question_library");
        List<StuQuestionLibraryRy> list = stuQuestionLibraryRyService.selectStuCourseContentList(questionLibrary);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取课后练习模块子目录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "catalogId", value = "课后练习模块id", required = true),
            @ApiImplicitParam(name = "memberId", value = "会员id", required = true)

    })
    @GetMapping("/getCourseExercisesCatalog")
    public TableDataInfo getCourseExercisesCatalog(String catalogId, String memberId) {
        StuCommonClassifyCatalog commonClassifyCatalog = new StuCommonClassifyCatalog();
        commonClassifyCatalog.setCatalogParentId(catalogId);
        commonClassifyCatalog.setMemberId(memberId);
        List<StuCommonClassifyCatalog> cataloglist = stuCommonClassifyCatalogService.selectStuCommonClassifyCatalogList(commonClassifyCatalog);
        //List<StuCommonClassifyCatalog> list = commonClassifyCatalogService.getClassifyCatalogTree(cataloglist,classifyCatalog);
        return getDataTable(cataloglist);
    }

    @ApiOperation(value = "获取课后练习习题内容")
    @ApiImplicitParam(name = "catalogId", value = "课后练习模块子目录id", required = true)
    @GetMapping("/getCourseExercisesContent")
    public TableDataInfo getCourseExercisesContent(String catalogId) {
        StuCommonClassifyCatalog commonClassifyCatalog = new StuCommonClassifyCatalog();
        commonClassifyCatalog.setCatalogParentId(catalogId);
        List<StuCommonClassifyCatalog> cataloglist = stuCommonClassifyCatalogService.selectStuCommonClassifyCatalogList(commonClassifyCatalog);
        //没有子目录的情况,用本目录id
        if (cataloglist != null && cataloglist.size() == 0) {
            commonClassifyCatalog.setId(catalogId);
            cataloglist.add(commonClassifyCatalog);
        }
        List<StuCommonClassifyCatalog> list = stuCommonClassifyCatalogService.getCourseCatalogTree(cataloglist);
        return getDataTable(list);
    }


    @ApiOperation(value = "保存课后练习答题结果")
    @PostMapping("/saveCourseExercisesResult")
    public AjaxResult saveCourseExercisesResult(@RequestBody CourseExercisesResultVO courseExercisesResult) {
        // 获取用户信息
        ClsMember clsMember = clsMemberMapper.selectById(courseExercisesResult.getMemberId());

        StuCourseExercisesResult stuCourseExercisesResult = new StuCourseExercisesResult();
        stuCourseExercisesResult.setMemberId(courseExercisesResult.getMemberId());
        stuCourseExercisesResult.setCourseId(courseExercisesResult.getCourseId());
        stuCourseExercisesResult.setCourseItemId(courseExercisesResult.getCourseItemId());
        stuCourseExercisesResult.setExercisesCatalogId(courseExercisesResult.getExercisesCatalogId());
        stuCourseExercisesResult.setUserAnswer(JSON.toJSONString(courseExercisesResult.getAnswerDetails()));

        outLoop:
        for (CourseExercisesResultDetail answerDetail : courseExercisesResult.getAnswerDetails()) {
            // 获取类型
            StuCommonClassifyCatalog stuCommonClassifyCatalog = stuCommonClassifyCatalogService.selectStuCommonClassifyCatalogById(answerDetail.getQuestionTypeCatalogId());
            if (stuCommonClassifyCatalog != null && stuCommonClassifyCatalog.getCatalogName() != null && stuCommonClassifyCatalog.getCatalogName().equals("命题训练")) {

                for (CourseExercisesResultDetail.AnswerDetail detail : answerDetail.getAnswerDetails()) {
                    try {
                        // 获取问题信息
                        StuQuestionLibraryRy questionLibraryRy = stuQuestionLibraryRyService.selectStuQuestionLibraryRyById(Long.parseLong(detail.getQuestionId()));
                        stuCourseExercisesResult.setApproveResult(AiUtil.appCall(detail.getAnswnerResult(), questionLibraryRy.getQuestionTitle(), clsMember.getGrade()));
                        break outLoop;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }

        int result = stuCourseExercisesResultService.insertStuCourseExercisesResult(stuCourseExercisesResult);
        if (result > 0) {
            return AjaxResult.success("保存成功");
        } else {
            return AjaxResult.error("保存失败");
        }

    }

    @ApiOperation(value = "获取课后练习答题结果汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "会员id", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", required = true),
            @ApiImplicitParam(name = "exercisesCatalogId", value = "训练类型目录id", required = true),
            @ApiImplicitParam(name = "questionTypeCatalogId", value = "题型目录id", required = true),

    })
    @PostMapping("/getCourseExercisesResult")
    public TableDataInfo getCourseExercisesResult(String memberId, String courseId, String exercisesCatalogId, String questionTypeCatalogId) {
        StuCourseExercisesResult stuCourseExercisesResult = new StuCourseExercisesResult();
        stuCourseExercisesResult.setMemberId(memberId);
        stuCourseExercisesResult.setCourseId(courseId);
        stuCourseExercisesResult.setExercisesCatalogId(exercisesCatalogId);
        stuCourseExercisesResult.setQuestionType(questionTypeCatalogId);
        List<StuCourseExercisesResult> list = stuCourseExercisesResultService.selectStuCourseExercisesResultList(stuCourseExercisesResult);
        for (StuCourseExercisesResult courseExercisesResult : list) {
            courseExercisesResult.setAnswerDetails(JSON.parseArray(courseExercisesResult.getUserAnswer(), CourseExercisesResultDetail.class));
        }
        return getDataTable(list);
    }

    @ApiOperation(value = "获取某个试题的答题结果", hidden = true)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "member_id", value = "会员id", required = true),
            @ApiImplicitParam(name = "question_id", value = "试题id", required = true),
    })
    @PostMapping("/getExercisesAnswnerResult")
    public TableDataInfo getExercisesAnswnerResult(String member_id, String question_id) {
        StuCourseExercisesResult stuCourseExercisesResult = new StuCourseExercisesResult();
        stuCourseExercisesResult.setMemberId(member_id);
        stuCourseExercisesResult.setQuestionId(question_id);
        List<StuCourseExercisesResult> list = stuCourseExercisesResultService.selectStuCourseExercisesAnswnerResult(stuCourseExercisesResult);
        return getDataTable(list);
    }

    @GetMapping("/composition")
    public AjaxResult compositionList(Integer pageNo, Integer pageSize) {
        return AjaxResult.success(stuCourseExercisesResultService.page4CompositionByMemberId(pageNo, pageSize, UserContextUtil.currentUser().getId()));
    }

}
